﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Diagnostics.Contracts;

namespace YasharEl.Infrastructure.EntityModel.Validation
{
    [Serializable]
    public class EntityValidationException : DomainModelException
    {
        private readonly IList<IInvalidValueInfo> _errors;

        public IList<IInvalidValueInfo> Errors
        {
            get { return _errors; }
        }

        public EntityValidationException(IList<IInvalidValueInfo> errors)
            :base("Entity is not valid. Check errors list for more details.")
        {
            Contract.Requires<ArgumentNullException>(errors != null, "errors could not be null.");
            _errors = new List<IInvalidValueInfo>(errors);
        }

        protected EntityValidationException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }
    }
}
